#pragma once
#include <boost/scoped_ptr.hpp>
#include "BulletTriangleMeshFwd.hpp"
#include "ImportExport.hpp"

class btBroadphaseInterface;
class btDefaultCollisionConfiguration;
class btCollisionDispatcher;
class btSequentialImpulseConstraintSolver;
class btDiscreteDynamicsWorld;
class btCollisionShape;
struct btDefaultMotionState;
class btRigidBody;

namespace he
{
	class MapRenderer;

	//! Game physics implementation.
	class WorldPhysics : boost::noncopyable
	{
		// Attributes
	private:
		//! Broadphase.
		std::auto_ptr<btBroadphaseInterface> m_pBroadPhase;
		//! Collision configuration.
		std::auto_ptr<btDefaultCollisionConfiguration> m_pCollisionConf;
		//! Collision dispatcher.
		std::auto_ptr<btCollisionDispatcher> m_pCollisionDispatcher;
		//! Physics solver.
		std::auto_ptr<btSequentialImpulseConstraintSolver> m_pPhysicsSolver;
		//! World.
		std::auto_ptr<btDiscreteDynamicsWorld> m_pWorld;
		//! Map renderer.
		he::MapRenderer *m_pMapRenderer;
		//! Map triangle mesh.
		BulletTriangleMeshPtr_t m_pMapTrimesh;
		//! Map collision shape.
		boost::scoped_ptr<btCollisionShape> m_pMapCollisionShape;
		//! Motion state for world.
		boost::scoped_ptr<btDefaultMotionState> m_pMapMotionState;
		//! Rigid body for map.
		boost::scoped_ptr<btRigidBody> m_pMapRigidBody;

		// Operations
	public:
		//! Update.
		void HE_ENGINE_API update(float Timer);
		//! Associate map renderer.
		void HE_ENGINE_API associate(he::MapRenderer *pMapRenderer);

		// Construction/Destruction
	public:
		HE_ENGINE_API WorldPhysics();
		HE_ENGINE_API ~WorldPhysics();
	};
} /*he*/
